/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-03-02
 * Time: 23:33
 */
class Solution21 {
    public String reverseWords(String s) {
        String[] str = s.split(" ");
        int n = str.length;
        StringBuilder builder = new StringBuilder();
        for(int i = n - 1 ; i >= 0 ; i--){
            String curStr = str[i];
            if(curStr.length() > 0){
                builder.append(curStr);
                builder.append(" ");
            }
        }
        return builder.toString().trim();
    }
}
public class Test21 {
}
